package com.example.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.example.demo.po.Album;
import com.example.demo.po.Config;
import com.example.demo.po.Nav;
import com.example.demo.po.News;
import com.example.demo.po.Tv;
import com.example.demo.po.Work;
import com.example.demo.service.AlbumService;
import com.example.demo.service.ConfigService;
import com.example.demo.service.NavService;
import com.example.demo.service.NewService;
import com.example.demo.service.TvService;
import com.example.demo.service.WorkService;

@Controller
@RequestMapping("/admin")
public class IndexController {
	
	@Autowired
	private NavService navService;
	
	@Autowired
	private ConfigService configService;
	
	@Autowired
	private TvService tvService;
	
	@Autowired	
	private NewService newService;
	
	@Autowired
	private AlbumService albumService;
	
	@Autowired
	private WorkService workService;
	
	@RequestMapping(value="/index.action",method=RequestMethod.GET)
	public String index(Model model){
		List<Album> album = albumService.getImg();
		model.addAttribute("album", album);
		
		List<Nav> navList = navService.selectAll();
		model.addAttribute("navList", navList);
		
		//公司名称：天津唐人影视股份有限公司
		Config config_Name = configService.selectById(1);
		model.addAttribute("config_Name", config_Name);
		
		//logo图片地址：images/logo_new.png
		Config config_Logo = configService.selectById(2);
		model.addAttribute("config_Logo", config_Logo);

		//页脚logo图片地址：images/tr_logo_small_new.jpg
		Config config_Slogo = configService.selectById(3);
		model.addAttribute("config_Slogo", config_Slogo);
		
		//联系电话：010-85655758
		Config config_Tel = configService.selectById(4);
		model.addAttribute("config_Tel", config_Tel);
		
		//备案信息：津ICP备13003281号
		Config config_ICP = configService.selectById(5);
		model.addAttribute("config_ICP", config_ICP);
		
		//版权所有COPYRIGHT © 2013 TANGREN.COM LIMITED. ALL RIGHTS RESERVED.
		Config config_Copyright = configService.selectById(6);
		model.addAttribute("config_Copyright", config_Copyright);
		
		//新浪微博：sina
		Config config_sina = configService.selectById(7);
		model.addAttribute("config_sina", config_sina);
		
		//腾讯微博：tencent
		Config config_tencent = configService.selectById(8);
		model.addAttribute("config_tencent", config_tencent);

		//海报图片地址：images/wxsy.jpg
		Config config_poster = configService.selectById(9);
		model.addAttribute("config_poster", config_poster);
		
		List<Work> workList = workService.selectAll();
		model.addAttribute("workList", workList);
		
		List<News> newsList = newService.selectAll();
		model.addAttribute("newsList", newsList);
		

		
		return "/index";
		
	}
	
}
